# nodemon --watch fetcher/05request_pic.py --exec 'uv run fetcher/05request_pic.py'
import requests


url =  'https://img0.baidu.com/it/u=540025525,3089532369&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500'
# url = 'http://localhost:3000/'
# param = {
# "keywords": "⼈⼒资源",
# "搜 索": "搜 索"
# }
# header = {
# 'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36'
# # 其他条件 refer
# }

# resp = requests.get(url)
# # resp.encoding = 'UTF-8' # fix 中文乱码
# # print(resp.text)

# res = resp.content
# print("res:",len(res))
# with open('./tmp/baidu_pic.jpg', 'wb') as f:
#     f.write(res)

#方式2
from urllib.request import urlretrieve
urlretrieve(url,'./tmp/baidu_pic2.jpg')